﻿@{
	Layout = "";
	OrgDepartment item = ViewBag.item;
	var fk_Parents = fsql.Select<OrgDepartment>().ToList();
}

<div class="box">
	<div class="box-header with-border">
		<h3 class="box-title" id="box-title"></h3>
	</div>
	<div class="box-body">
		<div class="table-responsive">
			<form id="form_add" method="post">
				@Html.AntiForgeryToken()
				<input type="hidden" name="__callback" value="edit_callback" />
				<div>
					<table cellspacing="0" rules="all" class="table table-bordered table-hover" border="1" style="border-collapse:collapse;">
						@if (item != null) {
							<tr>
								<td>主键(自增)</td>
								<td><input name="Id" type="text" readonly class="datepicker" style="width:20%;background-color:#ddd;" /></td>
							</tr>
						}
						<tr>
							<td>父级id</td>
							<td id="Parent_td"></td>
						</tr>
					    <tr>
							<td>名称</td>
							<td><input name="Name" type="text" class="datepicker" style="width:60%;" /></td>
						</tr>
					    <tr>
							<td>名称：技术部-前端</td>
							<td><input name="FullName" type="text" class="datepicker" style="width:60%;" /></td>
						</tr>
					    <tr>
							<td>创建时间</td>
							<td><input name="CreateTime" type="text" class="datepicker" /></td>
						</tr>
					    <tr>
							<td>更新时间</td>
							<td><input name="UpdateTime" type="text" class="datepicker" /></td>
						</tr>
					    <tr>
							<td>逻辑删除</td>
							<td id="IsDeleted_td"><input name="IsDeleted" type="checkbox" value="true" /></td>
						</tr>
					    <tr>
							<td>排序</td>
							<td><input name="Sort" type="text" class="form-control" data-inputmask="'mask': '9', 'repeat': 6, 'greedy': false" data-mask style="width:200px;" /></td>
						</tr>
						<tr>
							<td width="8%">&nbsp</td>
							<td><input type="submit" value="@(item == null ? "添加" : "更新")" />&nbsp;<input type="button" value="取消" /></td>
						</tr>
					</table>
				</div>
			</form>

		</div>
	</div>
</div>

<script type="text/javascript">
	(function () {
		top.edit_callback = function (rt) {
			if (rt.code == 0) return top.mainViewNav.goto('./?' + new Date().getTime());
			alert(rt.message);
		};
        $('#Parent_td').html(yieldTreeSelect(yieldTreeArray(@Html.Json(fk_Parents), null, 'Id', 'ParentId'), '{#ame}', 'Id')).find('select').attr('name', 'ParentId');

		var form = $('#form_add')[0];
		var item = null;
		@if (item != null) {
			<text>
			item = @Html.Json(item);
			fillForm(form, item);
			</text>
		}
		top.mainViewInit();
	})();
</script>